package com.HuangJiaQing.www.controller;


import com.HuangJiaQing.www.model.Marketers;
import com.HuangJiaQing.www.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * @author HONOR
 * @date 2022/7/27 15:54
 */

@Controller
public class LoginController {
    @Autowired
    private LoginService loginService;

    @RequestMapping("/")
    public String index(Model model){
        List<Marketers> visit = loginService.visit();
        model.addAttribute("marketers",visit);
        return "index";
    }
    @RequestMapping(value = "/toLogin", method = RequestMethod.GET)
    public String toLogin() {
        return "login";
    }

    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public String login(Model model, String username, String password, String login) {
        String s = loginService.login(model, username, password, login);
        return s;

    }


}
